package com.pachong.controller;

import com.pachong.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

//前端请求编写
@RestController
public class ContentController {

    @Autowired//调用对象contentService
    private ContentService contentService;

    @GetMapping("/parse/{keyword}")//解析调用方法放入数据库中content
    public  Boolean parse(@PathVariable("") String keyword) throws Exception {
        return contentService.parseContent(keyword);
    }

    @GetMapping("/search/{keyword}/{pageNo}/{pageSize}")//获取返回值，发起search请求
    public List<Map<String,Object>> search(@PathVariable("keyword") String keyword,//关键字
                                           @PathVariable("pageNo") int pageNo,//页数
                                           @PathVariable("pageSize") int pageSize) throws IOException {//数据数
        return contentService.searchPageHighlightBuilder(keyword,pageNo,pageSize);//调用业务类
    }
}
